#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using tl = tuple < int, int, int >;
using vec = vector < int >;
using veg = vector < pii >;

int read() {
    int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-',ch = getchar();
    while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 3e5 + 10;
const int T = 3e5;

pii stk[N << 1];

int fa[N << 1], n, top, siz[N << 1];
ll ans;
pii cnt[N << 1];
veg pot[N << 2];

map < pii, int > f;

void ins(int xl, int xr, pii v, int o = 1, int l = 1, int r = n) {
	if(xl == l && xr == r) return pot[o].pb(v), void(); int mid = l + r >> 1;
	if(xr <= mid) ins(xl, xr, v, o << 1, l, mid); else if(xl > mid) ins(xl, xr, v, o << 1 | 1, mid + 1, r);
	else ins(xl, mid, v, o << 1, l, mid), ins(mid + 1, xr, v, o << 1 | 1, mid + 1, r);
}

int gf(int x) { while(x != fa[x]) x = fa[x]; return x; }

void merge(int x, int y) {
	x = gf(x); y = gf(y); if(x == y) return;
	if(siz[x] < siz[y]) swap(x, y);
	ans -= 1ll * cnt[x].fi * cnt[x].se; ans -= 1ll * cnt[y].fi * cnt[y].se;
	stk[++top] = { x, y };
	siz[x] += siz[y]; cnt[x].fi += cnt[y].fi; cnt[x].se += cnt[y].se; fa[y] = x;
	ans += 1ll * cnt[x].fi * cnt[x].se;
}

void undo(int x, int y) {
	ans -= 1ll * cnt[x].fi * cnt[x].se;
	siz[x] -= siz[y]; cnt[x].fi -= cnt[y].fi; cnt[x].se -= cnt[y].se; fa[y] = y;
	ans += 1ll * cnt[x].fi * cnt[x].se; ans += 1ll * cnt[y].fi * cnt[y].se;
}

void solve(int o = 1, int l = 1, int r = n) {
	int cur = top;
	for(auto v : pot[o]) merge(v.fi, v.se + T);
	int mid = l + r >> 1;
	if(l == r) printf("%lld ", ans);
	else solve(o << 1, l, mid), solve(o << 1 | 1, mid + 1, r);
	while(top > cur) undo(stk[top].fi, stk[top].se), top--;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
	n = in;
	rep(i, 1, n) {
		int x = in, y = in;
		if(!f.count({ x, y })) f[{ x, y }] = i;
		else ins(f[{ x, y }], i - 1, { x, y }), f.erase({ x, y });
	}
	for(auto v : f) ins(v.se, n, v.fi);
	rep(i, 1, T) fa[i] = i, cnt[i].fi = 1, siz[i] = 1;
	rep(i, T + 1, T + T) fa[i] = i, cnt[i].se = 1, siz[i] = 1;
	solve(1);
	return 0;
}
